package com.example.sup.conttroller;

import com.example.sup.aspect.annotation.CheckLogin;
import com.example.sup.conttroller.request.QueryEcRequest;
import com.example.sup.conttroller.response.ServerResponse;
import com.example.sup.entity.UserInfo;
import com.example.sup.service.ElectricityConsumptionInfoService;
import com.example.sup.vo.ElectricityConsumptionInfoVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName ElectricityConsumptionInfoController
 * @Description {TODO}
 * @Author 李哲
 * @Date 16:13 2024/7/30
 * @Version 1.0
 */
@RestController
@RequestMapping("electricityConsumptionInfo")
@Validated
@Slf4j
public class ElectricityConsumptionInfoController {

    @Resource
    private ElectricityConsumptionInfoService electricityConsumptionInfoService;

    @PostMapping("/queryEC")
    @CheckLogin
    public ServerResponse<List> queryEc(UserInfo userInfo,
                                        @RequestBody QueryEcRequest  queryEcRequest){
        //TODO 1.参数校验

        log.info("登录的用户信息:{}",userInfo);
        //TODO 2.调用service
        List<ElectricityConsumptionInfoVO> electricityConsumptionInfoVOList = electricityConsumptionInfoService.totalElectricityConsumption(queryEcRequest.getPrisonId());

        //TODO 3.返回Model
        return ServerResponse.<List>success(electricityConsumptionInfoVOList);
    }
    }